#!/usr/bin/python
# POLITEIA_LICENSE

import graphic
import input

from ogre.renderer.OGRE import Timer

class GameHandler(object):
    def __init__(self, path, fullscreen):
        self.Running = False
        
        self.GraphicManager = graphic.GraphicManager("Demo1", path, fullscreen)
        self.InputManager = input.InputManager(path,
                self.GraphicManager.get_window_handler())
        
    def deinit(self):
        del self.InputManager
        del self.GraphicManager
        
        
    def run(self):
        self.Running = True
        timer = Timer()
        cnt = 0
        cur_time = 0
        last_time = 0
        while self.Running:
            cur_time = timer.getMilliseconds()
            diff = cur_time - last_time
            
            self.InputManager.update()
            self.GraphicManager.update(diff)
            
            last_time = cur_time
